<template>
  <el-dialog title="申诉登记" :visible.sync="dialogVisible" width="800px">
    <el-form ref="appealRegisterForm" label-width="80px" :rules="rules" :model="appealRegisterForm">
      <el-row :gutter="24">
        <el-col :span="12">
          <el-form-item label="问题类型" prop="wtlx00">
            <el-select v-model="appealRegisterForm.wtlx00" placeholder="请选择" clearable style="width: 100%">
              <el-option v-for="item in wtlx00Options" :key="item.value" :value="item.value" :label="item.label"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="联系方式" prop="lxfs00">
            <el-input v-model="appealRegisterForm.lxfs00" placeholder="请输入" clearable />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="24">
        <el-col :span="24">
          <el-form-item label="问题描述" prop="wtms00">
            <el-input v-model="appealRegisterForm.wtms00" type="text" placeholder="请输入" clearable />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button size="small" type="primary" @click="submit" :loading="loading">提 交</el-button>
      <el-button size="small" @click="handleClose">关 闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import {equityMaintainApi} from "@/api/index.js"

export default {
  name: "appeal-register",
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      wtlx00Options: [
        {
          label: '劳动报酬',
          value: '1'
        },
        {
          label: '工伤医疗',
          value: '2'
        },
        {
          label: '经济补偿',
          value: '3'
        },
        {
          label: '其他问题',
          value: '4'
        }
      ],
      appealRegisterForm: {
        lxfs00: '',
        wtlx00: '',
        wtms00: '',
        yzxh00: sessionStorage.getItem("yzxh")
      },
      rules: {
        wtlx00: [
          { required: true, message: '请选择问题类型', trigger: 'change' },
        ],
        wtms00: [
          { required: true, message: '请输入问题描述', trigger: 'blur' },
        ],
        lxfs00: [
          { required: true, message: '请输入联系方式', trigger: 'blur' },
        ]
      },
      loading: false
    }
  },
  methods: {
    submit() {
      this.$refs.appealRegisterForm.validate(valid => {
        if (valid) {
          this.loading = true
          equityMaintainApi.addRightProtection({...this.appealRegisterForm}).then(() => {
            this.$emit('handleSuccess')
          }).finally(() => {
            this.loading = false
          })
        }
      })
    },
    handleClose() {
      this.handleReset()
      this.$emit('handleClose')
    },
    handleReset() {
      this.appealRegisterForm = {
        lxfs00: '',
        wtlx00: '',
        wtms00: '',
        yzxh00: ''
      }
    }
  }
}
</script>

<style scoped lang="scss">

</style>